using BasicData.API.Application.Command;
using BasicData.API.Dtos;
using BasicData.ErrorCode;
using MediatR;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace BasicData.API.Application.Mediator
{
    /// <summary>
    /// 生产信息中介者实现
    /// </summary>
    public class ProductionInfoMediator : IProductionInfoMediator
    {
        private readonly IMediator _mediator;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator">MediatR中介者</param>
        public ProductionInfoMediator(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 获取所有生产信息
        /// </summary>
        /// <returns>生产信息列表</returns>
        public async Task<APIResult<List<ProductionInfoDTO>>> GetAllProductionInfosAsync()
        {
            var command = new GetProductionInfoCommand();
            return await _mediator.Send(command);
        }
        
        /// <summary>
        /// 根据ID获取单个生产信息
        /// </summary>
        /// <param name="command">查询命令</param>
        /// <returns>生产信息</returns>
        public async Task<APIResult<ProductionInfoWithGoodsDTO>> GetProductionInfoByIdAsync(GetProductionInfoByIdCommand command)
        {
            return await _mediator.Send(command);
        }
        
        /// <summary>
        /// 添加生产信息
        /// </summary>
        /// <param name="command">添加生产信息命令</param>
        /// <returns>添加结果</returns>
        public async Task<APIResult<ProductionInfoDTO>> AddProductionInfoAsync(AddProductionInfoCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 修改生产信息
        /// </summary>
        /// <param name="command">修改生产信息命令</param>
        /// <returns>修改结果</returns>
        public async Task<APIResult<ProductionInfoDTO>> UpdateProductionInfoAsync(UpdateProductionInfoCommand command)
        {
            return await _mediator.Send(command);
        }
        
        /// <summary>
        /// 批量删除生产信息（软删除）
        /// </summary>
        /// <param name="command">批量删除命令</param>
        /// <returns>删除结果</returns>
        public async Task<APIResult<bool>> BatchDeleteProductionInfosAsync(BatchDeleteProductionInfoCommand command)
        {
            return await _mediator.Send(command);
        }
        
        /// <summary>
        /// 单个产品信息软删除
        /// </summary>
        /// <param name="command">软删除命令</param>
        /// <returns>删除结果</returns>
        public async Task<APIResult<bool>> SoftDeleteProductionAsync(SoftDeleteProductionCommand command)
        {
            return await _mediator.Send(command);
        }

       
    }
} 
